<!-- 头部组件 -->
<template>
  <div id="nav">
    <newsHome/>
    <div id="home">
      <div class="content">
        <div class="banner">
          <ul class="clearfix">
            <li>
              <img src="https://i01piccdn.sogoucdn.com/4777f6046761123c" alt="">
              <div class="text-box">
                <h2>习近平在浙江考察时强调统筹推进疫情防控11111</h2>
              </div>
            </li>
          </ul>
        </div>
        <div class="newsList">
          <ul>
            <li v-for="(item,index) in arrList" :key="index">
              <!-- <a href="#">
                            <h2>{{item.title}}</h2>
                            <p>{{item.detail}}</p>
              </a>-->
              <router-link :to="'/article/'+item.id">
                <div class="left">
                  <h2>{{item.title}}</h2>
                  <p>来源：{{item.source}}</p>
                  <p>{{item.date}}</p>
                </div>
                <div class="right">
                  <img :src="item.image" alt="">
                </div>
              </router-link>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import newsHome from "@/components/news/newsHome";
export default {
  data() {
    return {
      arrList: []
    };
  },
  components: {
    newsHome
  },
  mounted() {
    // 获取数据
    this.fetchData();
  },
  methods: {
    fetchData() {
      var _this = this;
      this.$http
        .get("src/data/index.data")
        .then(function(res) {
          _this.arrList = res.data;
        })
        .catch(function(err) {
          console.log(err);
        });
    }
  }
};
</script>
<style scoped>
.head {
  width: 100%;
  height: 0.7rem;
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgb(59, 62, 223);
  border-bottom: 1px solid #e8eaec;
  z-index: 99;
}
.l-btn {
  width: 30%;
  height: 1rem;
  background: url(../../assets/images/history.png) no-repeat 0 0;
  margin-top: 0.5rem;
  background-size: 0.6rem;
}
.header {
  width: 30%;
  font-size: 0.4rem;
  color: #f2f4f5;
}
.zero {
  width: 30%;
}
.nav {
  width: 100%;
  z-index: 2;
  background: #fff;
  margin-top: 0.7rem;
}
.nav ul {
  width: 100%;
  height: 0.8rem;
  display: flex;
}
.nav ul li {
  width: 20%;
}
.nav ul li a {
  display: block;
  line-height: 0.8rem;
  text-align: center;
}
.nav ul li.active a {
  height: 0.7rem;
  border-bottom: 0.05rem solid #5477b2;
  color: #5477b2;
}
.banner {
  position: relative;
  overflow: hidden;
  z-index: 1;
}
.banner ul li {
  width: 6.4rem;
  height: 3rem;
  float: left;
  position: relative;
}
.banner ul li img {
  width: 100%;
  display: block;
}
.banner ul li .text-box {
  width: 100%;
  padding: 0 0.3rem;
  height: 0.6rem;
  position: absolute;
  left: 0;
  bottom: 0.25rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
}
.text-box h2 {
  font-size: 0.26rem;
  font-weight: normal;
  margin-top: 0.22rem;
  line-height: 100%;
  margin-bottom: 0.22rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.text-box p {
  /* line-height:100%; */
  font-size: 0.3rem;
}
.newsList ul li {
  padding: 0.1rem;
  display: flex;
}
.left {
  width: 70%;
}
.right {
  width: 30%;
  height: 60%;
}
.right img {
  width: 100%;
  height: 100%;
}
</style>